package com.demo.sys.controller;

import com.demo.sys.entity.req.UserVO;
import com.demo.sys.service.ClientUserService;
import common.constant.HttpStatus;
import common.utils.ParamUtils;
import common.utils.Result;
import common.utils.msg.RespData;
import common.utils.msg.RespFailMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>登入</p>
 *@author zwy
 *@date 2025/3/14 11:06
*/

@RestController
@Api(tags = "登录")
@RequestMapping("/api")
@ApiResponses({
        @ApiResponse(code = HttpStatus.UNAUTHORIZED, message = "授权过期(登录过期)", response = Result.class),
        @ApiResponse(code = HttpStatus.ERROR, message = "通用错误提示", response = Result.class)}
)
public class LoginController {
    @Autowired
    public ClientUserService clientuser;
    /**
     * 登入
     */
    @PostMapping("/login")
    @ApiOperation(value = "平台登入")
    public RespData<?> login(@RequestBody UserVO vo) {
        String account = vo.getAccount();
        String password = vo.getPassword();
        ParamUtils.check(account);
        if (!StringUtils.isBlank(password)) {
          //  password =
        } else {
            return RespData.fail(RespFailMsg.OPT_TIMEOUT);
        }
        /**登入用户id解码
         *
         */
        // account = DataCryptoUtils.accountPage(account);
        //演示所以不给密码加密解密
        if (StringUtils.isBlank(account)) {
            return RespData.fail(RespFailMsg.OPT_TIMEOUT);
        }
       // vo.setAccount(account);
       return clientuser.userLogin(account,password);
    }
}